#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 5e5 + 10, INF = 0x3f3f3f3f;

int n, q, root;
int h[N], e[N * 2], ne[N * 2], idx;
int qh[N], qe[N * 2], qne[N * 2], num[N * 2], qidx;
int f[N], ans[N];
bool st[N];
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
void qadd(int a, int b, int id){
    qe[qidx] = b, num[qidx] = id, qne[qidx] = qh[a], qh[a] = qidx++;}

int find(int x) { return x != f[x] ? f[x] = find(f[x]) : f[x]; }

void tarjan(int x)
{
    st[x] = 1;
    for (int i = h[x]; i != -1; i = ne[i]) {
        int y = e[i];
        if (st[y] != 1) {
            tarjan(y);
            f[y] = x;
        }
    }
    for (int i = qh[x]; i != -1; i = qne[i]) {
        int y = qe[i];
        if (st[y] == 1)
            ans[num[i]] = find(y);
    }
}
void solve()
{
    memset(h, -1, sizeof h);
    memset(qh, -1, sizeof qh);
    cin >> n >> q >> root;
    for (int i = 1, u, v; i < n; i++) {
        f[i] = i;
        cin >> u >> v;
        add(u, v), add(v, u);
    }
    f[n] = n;
    for (int i = 1, x, y; i <= q; i++) {
        cin >> x >> y;
        qadd(x, y, i), qadd(y, x, i);
    }
    tarjan(root);
    for (int i = 1; i <= q; i++)
        cout << ans[i] << '\n';
}

int main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int T = 1;
    // cin>>T;
    for (int i = 1; i <= T; i++) {
        solve();
    }
}